var a = getApp();

Page({
    data: {
        awardsList: {},
        animationData: {},
        btnDisabled: ""
    },
    gotoList: function() {
        wx.redirectTo({
            url: "../list/list"
        });
    },
    getLottery: function() {
        if ("disabled" != this.data.btnDisabled) {
            var t = this, n = 6 * Math.random() >>> 0, i = a.awardsConfig;
            n < 2 && (i.chance = !1), console.log(n), a.runDegs = a.runDegs || 0, a.runDegs = a.runDegs + (360 - a.runDegs % 360) + (1440 - 45 * n);
            var e = wx.createAnimation({
                duration: 6e3,
                timingFunction: "ease"
            });
            t.animationRun = e, e.rotate(a.runDegs).step(), t.setData({
                animationDataCopy: e.export(),
                btnDisabled: "disabled"
            });
            var s = wx.getStorageSync("winAwards") || {
                data: []
            };
            s.data.push(i.awards[n].name + "1个"), wx.setStorageSync("winAwards", s), setTimeout(function() {
                wx.showModal({
                    title: "恭喜",
                    content: "获得" + i.awards[n].name,
                    showCancel: !1,
                    success: function() {
                        t.setData({
                            btnDisabled: ""
                        });
                    }
                });
            }, 6e3);
        }
    },
    onReady: function(t) {
        var n = this;
        a.awardsConfig = {
            chance: !0,
            awards: [ {
                index: 0,
                name: "MAC book",
                img: "/images/lotto/j1.jpg"
            }, {
                index: 1,
                name: "谢谢参与",
                img: "/images/lotto/j6.png"
            }, {
                index: 2,
                name: "小米电视",
                img: "/images/lotto/j3.jpg"
            }, {
                index: 3,
                name: "感应台灯",
                img: "/images/lotto/j4.jpg"
            }, {
                index: 4,
                name: "谢谢参与",
                img: "/images/lotto/j6.png"
            }, {
                index: 5,
                name: "美的电热水壶",
                img: "/images/lotto/j2.jpg"
            }, {
                index: 6,
                name: "小米移动电源",
                img: "/images/lotto/j5.jpg"
            }, {
                index: 7,
                name: "谢谢参与",
                img: "/images/lotto/j6.png"
            } ]
        };
        var i = a.awardsConfig.awards, e = i.length, s = [], o = 1 / e;
        n.setData({
            btnDisabled: a.awardsConfig.chance ? "" : "disabled"
        });
        wx.createContext();
        for (var r = 0; r < e; r++) s.push({
            turn: r * o + "turn",
            lineTurn: r * o + o / 2 + "turn",
            award: i[r].name,
            img: i[r].img
        });
        n.setData({
            awardsList: s
        });
        var g = wx.createAnimation({
            duration: 1e4,
            timingFunction: "linear"
        });
        n.animation = g, n.setData({
            animationData: g.export()
        });
        var m = 1;
        this.animation.rotate(360 * m).step(), this.setData({
            animationData: this.animation.export()
        }), this.ani = setInterval(function() {
            m += 1, this.animation.rotate(360 * m).step(), this.setData({
                animationData: this.animation.export()
            });
        }.bind(this), 1e4);
    },
    onShareAppMessage: function() {
        return {
            title: "",
            path: "/pages/demo/demo",
            success: function(a) {}
        };
    }
});